package cn.neusoft.controller;

import cn.neusoft.pojo.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController  // 包含了@ResponseBody
@RequestMapping("/emp")
public class EmpController {

//    @RequestMapping("/add")  //   /emp/add
    /*
     400 错误的请求参数
     405 错误的请求方式
     */
    @RequestMapping(path = "/add",params = {"empno"},method = {RequestMethod.POST,RequestMethod.GET})
    public String add(Integer empno,String ename){
        System.out.println("员工添加");
        System.out.println(empno+" "+ename);
        return "success";
    }

    /*
    1、req.getParameter("empno")  ename  job
    2、创建实体类对象  new Emp();
    3、 emp.setEmpno(..)  emp.setEname(..) emp.setJob(..)
     */
    @RequestMapping("/update")   //  /emp/update
    public String update(Emp emp){
        System.out.println("员工修改");
        System.out.println(emp);
        return "success";
    }

}
